<?php
defined('SEJUJOPEFDNGJSL') or exit('Access denied');
$action=$_GET['action'];
if ($action=="rknew"){
  $num=checkstr($_POST['num']);
  $productid=checkstr($_POST['productid']);
	if (!is_numeric(abs($num))) show_automsg('请输入数量',YMCURL.'productin');
    $db->query("select * from ld_product where id=".$productid,2);
    $c_result=$db->rs;
    
    if(empty($c_result)) show_automsg('产品编号不存在',YMCURL.'productin');
    $db->query("update  ld_product set num=num+".$num." where id=".$productid,4);
     
        $xrr['productid']=$productid;
        $xrr['productname']=checkstr(trim($c_result['productname']));
        $xrr['num']=$num;
        $xrr['addtime']=time();
        $xrr['adminname']=$_SESSION['houname'];
        $xrr['adminid']=$_SESSION['houid'];

        $sql=getinsertsql($xrr,'ld_rks');

        $db->query($sql,5);
        show_automsg('入库成功',YMCURL.'productin');

}
$prid=checkstr($_GET['prid']);
$tag=checkstr($_GET['tag']);
if(!empty($tag)){
$db->query("select * from ld_product where id='".$prid."'",2);
$rs1=$db->rs;
}
?>
<!-- <link rel="stylesheet" href="/images/datalist.css" type="text/css"> -->
<link rel="stylesheet" type="text/css" href="../css/pintuer.css">
<link rel="stylesheet" type="text/css" href="../css/admin.css">
<link rel="stylesheet" type="text/css" href="../css/manage.css">
</head>


<div class="righttop">
  <span class="icon-home"></span> 首页 <span class="gray">/</span> 产品管理 <span class="gray">/</span> 入库
</div>
<div class="panelbox">
    <div class="panel admin-panel">
        <div class="panel-head">
          <strong><span class="icon-shopping-cart"></span>
            入库列表
          </strong>
        </div>
        <div class="padding border-bottom" style="height: auto;overflow: hidden;">
          <ul class="search" style="float: left;">
            <li>
            </li>
          </ul>
          <div style="float: left;height: auto;overflow:hidden;">
            <form name="form1" method="post" action="main.php?lsaction=productin&action=rknew" onSubmit="return confirm('确定入库吗?\r确定入库将增加库存数量')">
              <input type="hidden" name="tag" value="<?php print "$tag";?>">
                  <label class="searchlabel">产品编号</label>
                  <input name="productid" type="text" id="productid" value="<?php echo $rs1["id"]?>" class="input sehinput">
                  <INPUT name="but2" type=text class=button_text  id="but2" onMouseDown="this.className='button_onmousedown'" onMouseOver="this.className='button_onmouseover'" onMouseOut="this.className='button_onMouseOut'" value="检查" onClick="thschk();" style="display:none"> <span id="thdiv"></span>
                  <label class="searchlabel">入库数量</label>
                  <input name="num" type="text" id="num" value="1" class="input sehinput" style="margin-right: 5px;">
                  <button class="button bg-main" type="submit"  id="but" value="" name="but"><sapn class="icon-check-square-o"></sapn> 确定</button>
            </form>
          </div>
        </div>
        <div class="body-content" style="padding:0px;">
          <!-- 表格表格 -->
          <table class="table table-hover text-center">
              <tr>
                <th>编号</th>
                <th>图片</th>
                <th>产品编号</th>
                <th>名称</th>
                <th>价格</th>
                <th>数量</th>
                <th>入库时间</th>
              </tr>
              <?
              $prid=$_GET['prid'];
              $sql="select * from ld_rks";
              if($prid){
                $sql.=" where productid=".$prid;

              }
              $db->query($sql);
              $list=$db->rs;

              //----------------
             foreach ($list as $key => $rs) {
                  $db->query("select * from ld_product where id='".$rs["productid"]."'",2);
                  $pro_res=$db->rs;

      ?>
         <tr>
              <td><?php echo $rs["id"]?></td>
              <td>
              <?php if(!empty($pro_res["proimg"])){?><a href="<?php echo $rs["proimg"]?>" target="_blank"><img src="<? echo $pro_res["proimg"]?>" height="50" border="0" /></a><?php }else echo "无";?></div>
                </div>
              </td>
              <td><?php echo $rs["productid"]?></td>
              <td><?php echo $rs["productname"]?></td>
              <td><?php echo $pro_res["price"]?></td>
              <td><?php echo $rs["num"]?></td>
              <td><?php echo date("y-m-d",$rs["addtime"])?></td>
            </tr>
              <?php
      }
      $db->free_result($result);
      ?>
            </table>
          <!-- 结束结束 -->
        </div>
    </div>
</div>
